package com.foreknow.demo6;

public class Y extends X{
    private String school;

    public String getSchool() {
        return school;
    }

    public void setSchool(String school) {
        this.school = school;
    }

    public void showinfo(){//方法重写(覆盖)：1.要有继承关系  2.子类重写父类的方法(规则:方法的名称,参数，返回值类型都相同)
        System.out.println("姓名: " + this.getName() + " 年龄: " + this.getAge() + " 学校: " + this.getSchool());
    }

    public static void main(String[] args) {
        Y y = new Y();
        y.setSchool("社会大学");
        y.setName("葛珊sb");
        y.setAge(23);
        y.showinfo();
    }
}
